package com.springboot.common.convert;


import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: TongRui乀
 * @Date: 2020-04-12 15:05
 * @description：
 */
@Component
public class String2DateConvert implements Converter<String, Date> {


    @Override
    public Date convert(String s) {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        try {
            return sdf.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
